package com.elinkway.infinitemovies.push;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.elinkway.infinitemovies.config.SettingManage;
import com.elinkway.infinitemovies.utils.LogUtils;

/**
 * 推送系统启动广播接收者
 * 
 * 与普通推送广播接收者PushBroadcastReceiver分离，以便系统禁用开机启动时不影响普通推送广播接收者的作用。
 * @author liuliwei
 *
 */
public class PushBootBroadcastReceiver extends BroadcastReceiver {

	public static final String TAG = "PushBroadcastReceiver";
	

	@Override
	public void onReceive(Context context, Intent intent) {
		if (null != context && null != intent) {
			String action = intent.getAction();
			if (TextUtils.isEmpty(action)) {
				return;
			}
			LogUtils.i(TAG, "action == " + action);
			// 开机启动广播
			if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
				if (SettingManage.getInstance().isPush()) {
					PushService.schedule(context);
				} else {
					PushService.unschedule(context);
				}
			}
		}
	}

}
